Re: [SQL] Week of year function? - Mailing list pgsql-sql

From Herouth Maoz
Subject Re: [SQL] Week of year function?
Date
Msg-id l03130302b43a3e85e018@[147.233.159.109]
Whole thread Raw
In response to Week of year function?  ("Zot O'Connor" <zot@zotconsulting.com>)
List pgsql-sql
At 21:52 +0200 on 22/10/1999, Zot O'Connor wrote:


> Is there a function to return the week of the year (0-51)?

Seems you only need to divide the day of the year by seven to reach that,
don't you?

Maybe you should try:

CREATE FUNCTION week( datetime ) RETURNS int4 AS ' SELECT int( date_part( ''day'', $1 - date_trunc( ''year'', $1 ) ) )
/7
 
' LANGUAGE 'sql';

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma




pgsql-sql by date:

Previous
From: Rich Ryan
Date:
Subject: Create index pretty slow
Next
From: "Moray McConnachie"
Date:
Subject: Re: [SQL] Week of year function?